package com.android.aiod.receiver;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import com.android.aiod.ui.activity.HomeActivity;

/**
 * 开启广播监听
 */
public class AutoBootBroadcastReceiver extends BroadcastReceiver {
    private final String ACTION_BOOT = "android.intent.action.BOOT_COMPLETED";

    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, "开机完毕~", Toast.LENGTH_SHORT).show();
        /**
         * 如果 收到系统 启动的广播，则启动 APP 主页
         */
        if (ACTION_BOOT.equals(intent.getAction())) {

            Log.i("test","开机完毕,打开首页");
            Toast.makeText(context, "打开首页", Toast.LENGTH_SHORT).show();
            Intent sayHelloIntent=new Intent(context, HomeActivity.class);
            sayHelloIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(sayHelloIntent);
        }
    }


}
